/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package table.model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import obj.LoginHistory;

/**
 *
 * @author Omar
 */
public class HistoryTableModel extends AbstractTableModel {

    String[] columnNames = {  "Person Id", "IP", "Date/Time" };
    ArrayList<LoginHistory> loginHistory;

    public HistoryTableModel() {
        loginHistory = new ArrayList<LoginHistory>();
    }
    
    
    
    @Override
    public int getRowCount() {
        return loginHistory.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex) {
            case 0: //column names
                return loginHistory.get(rowIndex).getPerson_ID();
            case 1:
                return loginHistory.get(rowIndex).getIP_Address();
            case 2: 
                return loginHistory.get(rowIndex).getDate();
            default:
                return null;
        }
    }
    
    public void addLoginHistory(LoginHistory history) {
        loginHistory.add(history);
    }
    
}
